/**
 * 项目名称:自定义一个异常，当用户两次密码不一致时抛出该异常
 *
 * @Author: 夏国倩
 * @Date: 2023/9/15 16:40
 * @Copyright
 */
package Exception;
public class Exception11 {
    private int password1;
    private int password2;

    public void setPassword(int password1, int password2) throws Exception {
        if (password1 == password2) {
            this.password1=password1;
            this.password2=password2;
        } else {
            throw new Exception("出现错误：两次输入的用户密码必须一致！");
        }
    }
    public void print(){
        System.out.println("输入的密码正确！密码为："+this.password1);
    }
}
